$(function () {
    layui.use(['table','layer','laydate','form'], function() {
        var table = layui.table;
        let layer = layui.layer;
        let form = layui.form;
        let laydate = layui.laydate;
        //第一个实例
        table.render({
            elem: '#demo'
            , toolbar: "#barDemo"
            , height: 'full-100'
            , url: '/getSituation' //数据接口
            , cols: [[ //表头
                {field: 'q_no', title: '接种编号', width: 100, fixed: 'left'}
                , {field: 's_name', title: '接种者姓名', width: 120}
                , {field: 's_sex', title: '性别', width: 100, sort: true}
                , {field: 's_vaccines', title: '接种疫苗', width: 150}
                , {field: 'q_date', title: '接种时间', width: 120}
                , {field: 'q_reaction', title: '接种反应', width: 100, sort: true}
            ]]
            , page: {
                limit: 5,
                limits: [1, 5, 10, 40, 100],
                layout: ['prev', 'page', 'next', 'count', 'limit', 'refresh']
            } //开启分页
        });
        var $ = layui.$, active = {
            reload: function(){
                var name = $('#search');
                //执行重载
                table.reload('demo', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                        name: name.val()
                    }
                }, 'data');
            }
        };
        $('#searchbt').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var $1 = layui.$, active1 = {
            reload: function(){
                //执行重载
                table.reload('demo', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                        yon: '异常'
                    }
                }, 'data');
            }
        };
        $('#abnormal').on('click', function(){
            var type = $(this).data('type');
            active1[type] ? active1[type].call(this) : '';
        });
        var $2 = layui.$, active2 = {
            reload: function(){
                //执行重载
                table.reload('demo', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                        yon: '正常'
                    }
                }, 'data');
            }
        };
        $('#unabnormal').on('click', function(){
            var type = $(this).data('type');
            active2[type] ? active2[type].call(this) : '';
        });
    })
})